<?php

#require_once('Imaging.php');
// Mode 7:JSCrop

class Imaging_ResizeMode7 extends Imaging {
  
  private $src_x; // selected top-left x-coordinate
  private $src_y; // selected top-left y-coordinate
  private $src_w; // selected height of image
  private $src_h; // selected height of image
  
  function set_param($h_param = array()){
    if (isset($h_param['src_x']))   $this->src_x = $h_param['src_x'];
    if (isset($h_param['src_y']))   $this->src_y = $h_param['src_y'];
    if (isset($h_param['src_w']))   $this->src_w = $h_param['src_w'];
    if (isset($h_param['src_h']))   $this->src_h = $h_param['src_h'];
  }
  
  function resize($max_w, $max_h){
    // Resize
    $new_image = imagecreatetruecolor($max_w, $max_h);
    imagecopyresampled($new_image, $this->image, 0, 0, 
       $this->src_x, $this->src_y, $max_w, $max_h, $this->src_w, $this->src_h);
    $this->image = $new_image;
    $this->resized = TRUE;
    return $this->get_dimension();
  }
  
}
?>